<html>
<head><meta charset="utf-8"><title>rustc rebuild proc macro on directory changes. · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html">rustc rebuild proc macro on directory changes.</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="200537843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustc%20rebuild%20proc%20macro%20on%20directory%20changes./near/200537843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html#200537843">(Jun 11 2020 at 12:37)</a>:</h4>
<p>Hey, I have a procedural macro that reads a user's directory at compile time, and I was wondering how I would ensure that rustc rebuilds the procedural macro in the users code whenever that directory changes? Having <code>include_str!</code> would work for changes to existing files, but I'd also like it to be rebuilt when new files or directories are added.</p>



<a name="200540062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustc%20rebuild%20proc%20macro%20on%20directory%20changes./near/200540062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html#200540062">(Jun 11 2020 at 12:58)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71858">https://github.com/rust-lang/rust/pull/71858</a> seems very relevant</p>



<a name="200540079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustc%20rebuild%20proc%20macro%20on%20directory%20changes./near/200540079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html#200540079">(Jun 11 2020 at 12:58)</a>:</h4>
<p>though not exactly what you need.</p>



<a name="200540307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustc%20rebuild%20proc%20macro%20on%20directory%20changes./near/200540307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html#200540307">(Jun 11 2020 at 13:00)</a>:</h4>
<p>tracking changes in directory contents however is not something that can be easily achieved even with cargo.</p>



<a name="200562107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustc%20rebuild%20proc%20macro%20on%20directory%20changes./near/200562107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustc.20rebuild.20proc.20macro.20on.20directory.20changes.2E.html#200562107">(Jun 11 2020 at 15:41)</a>:</h4>
<p>There is a longish discussion about this at <a href="https://internals.rust-lang.org/t/let-proc-macros-pass-information-to-the-compiler/8350">https://internals.rust-lang.org/t/let-proc-macros-pass-information-to-the-compiler/8350</a> with some mentions of workarounds.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>